package org.jeecg.modules.client.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.jeecg.common.api.vo.Result;
import org.jeecg.modules.client.entity.Client;
import org.jeecg.modules.client.service.ClientService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Auther: zhuzhuhong
 * @Description: 客户控制层
 * @Date: 2019/11/21 09:19
 */
@RestController
@RequestMapping(value = "/client/client")
public class ClientController {
    @Autowired
    private ClientService clientService;

    @GetMapping(value = "/list")
    public Result<IPage<Client>> getClientList() {
        Result<IPage<Client>> result = new Result<>();
        IPage<Client> ipage = new Page<>();
        List<Client> list = clientService.list();
        /*List<Client> resultList = new ArrayList<>(list.size());
        for (Client client : list) {
            client.setPassword("");
            resultList.add(client);
        }*/
        list.stream().forEach(client -> client.setPassword(""));
        ipage.setRecords(list);
        result.setResult(ipage);

        return result;
    }

}
